﻿using System.Data;
using Sunny.Core.DefinedData;
using Sunny.Core.Domain.Model;
using Sunny.Core.Domain.Repository;

namespace Sunny.Core.Domain
{
    /// <summary>
    /// The base of the service
    /// </summary>
    public abstract class BaseService
    {
        #region Transaction

        protected abstract IDbConnection GetConnection();

        protected void TransactionInsert(IRepository repository, IAggregateRoot model, IDbTransaction transaction)
        {
            repository.TransactionInsert(model, transaction);
        }

        protected void TransactionUpdate(IRepository repository, IAggregateRoot model, IDbTransaction transaction)
        {
            repository.TransactionUpdate(model, transaction);
        }

        protected void TransactionDelete(IRepository repository, IAggregateRoot model, IDbTransaction transaction)
        {
            repository.TransactionDelete(model, transaction);
        }

        #endregion
    }
}
